package ofpof.web.validator;

import ofpof.web.form.LoginForm;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

@Component
public class LoginFormValidator implements Validator {

	@Override
	public boolean supports(Class<?> clazz) {
		return LoginForm.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object object, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"user.email", "field.required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"user.password", "field.required");
	}

}
